package com.mingrisoft.servlet;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * 注册Servlet
 * @author Li YongQiang
 *
 */
public class AddServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;
	
	protected void doPost(HttpServletRequest request, HttpServletResponse response) 
			throws ServletException, IOException {
		// 设置response的编码
		response.setCharacterEncoding("UTF-8");
		// 获取PrintWriter
		PrintWriter out = response.getWriter();
		// 设置request的编码
		request.setCharacterEncoding("UTF-8");
		// 获取名称
		String name = request.getParameter("name");
		// 获取价格
		String price = request.getParameter("price");
		// 获取数量
		String count = request.getParameter("count");
		// 获取单位
		String unit = request.getParameter("unit");
		// 获取产地
		String add = request.getParameter("add");
		// 输出商品信息
		out.println("名称：" + name );
		out.println("价格：" + price);
		out.println("数量：" + count );
		out.println("单位：" + unit);
		out.println("产地：" + add );
		
		out.flush();
		out.close();
	}

}
